package main

import "fmt"

func main() {
	nums := []int{2, 7, 11, 15}
	target := 9

	fmt.Println(twoSum(nums, target))
}

func twoSum(nums []int, target int) []int {
	tempMap := make(map[int]int, len(nums))
	for index, num := range nums {
		tempMap[num] = index
	}

	for index1, num := range nums {
		index2, ok := tempMap[target-num]
		if ok && index1 != index2 {
			return []int{index1, index2}
		}
	}
	return []int{}
}
